#include "FileManager.h"
using namespace Managers;

FileManager::FileManager(string filePath) {
	this->filePath = filePath;
}

/* Opens a file in read and write mode, pointing the read and write pointers at the end of the file.
 * If the file doesn't exist it creates one.
 */
void FileManager::openFile() {

	char* fileNameStartingPosition = &(this->filePath[0]);

	fileStream.open(fileNameStartingPosition, ios::binary | ios::in | ios::out);

	if (fileStream.fail())
	{
		fileStream.clear();
		fileStream.open(fileNameStartingPosition, ios::binary | ios::trunc | ios::in | ios::out);
	}
}

void FileManager::closeFile() {
	this->fileStream.clear();
	this->fileStream.close();
}

FileManager::~FileManager() {}
